import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User:
 * Date: 2025-10-08
 * Time: 14:42
 */
public class demo3 {
    public static void main(String[] args) {
        Object locker = new Object();

        Thread t1 = new Thread(() -> {

                System.out.println("wait 之前");
            try{
                synchronized (locker){
                    locker.wait();
                }
                System.out.println("wait 之后");
            }catch (InterruptedException e){
                e.printStackTrace();
            }
        });

        Thread t2 = new Thread(() -> {
            Scanner sc = new Scanner(System.in);
            System.out.println("请输入内容，通知唤醒t1");
            sc.next();
            synchronized (locker){
                locker.notify();
            }
        });

        t1.start();
        t2.start();
    }
}
